const dgram = require('dgram')
const server = dgram.createSocket('udp4')

server.on('error', err => {
    console.log('服务器异常');
})

server.on('message', (msg, rinfo) => {
    console.log(`服务器接收到来自 ${rinfo.address}: ${rinfo.port}的 ${msg}`);
})

server.on('listening', () => {
    const address = server.address()
    console.log(`服务器监听 ${address.address}:${address.port}`);
})
server.on('connect', () => {
    console.log('连接成功');
})
server.bind(41234)